<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>定位</title>
    <style>
    .box{
        width: 400px;
        height: 400px;
        background: palegoldenrod;
        margin-bottom: 20px;
    }
    .box1{
        width: 200px;
        height: 200px;
        background: palegreen;
    }
    .box2{
        width: 200px;
        height: 200px;
        background: palevioletred;
    }
    /* 设置相对定位:1.占空间；2.参考坐标是自己；3.层级比普通元素高 */
    .xiangdui{
        position: relative;
        top: 100px;
        left: 100px;
    }
    /* 设置绝对定位:1.不占空间；2.参考坐标是浏览器；3.层级比普通元素高 */
    .juedui{
        background: pink;
        position: absolute;
        top: 100px;
        left: 100px;
    }
    .relative{
        position: relative;
    }
    /* 设置固定定位 */
    .guding{
        background: pink;
        position: fixed;
        right: 100px;
        bottom: 100px;
    }
    </style>
</head>
<body>
    <div class="box">
        <div class="box1 xiangdui"></div>
        <div class="box2"></div>
    </div>
    <div class="box">
        <div class="box1 juedui"></div>
        <div class="box2"></div>
    </div>
    <div class="box relative">
        <div class="box1 juedui"></div>
        <div class="box2"></div>
    </div>
    <div class="box">
        <div class="box1 guding"></div>
        <div class="box2"></div>
    </div>
</body>
</html>